﻿Imports System.Reflection
Public Class FontSetting

    Public Sub New()

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
        ' 在 InitializeComponent() 调用之后添加任何初始化。
    End Sub

    Private _ClassName As String = ""
    Public Property ClassNameFontSetting() As String
        Get
            Return _ClassName
        End Get
        Set(ByVal value As String)
            _ClassName = value
        End Set
    End Property

    Public Sub New(ByVal strFontName As String)
        InitializeComponent()
        ClassNameFontSetting = strFontName
    End Sub

    Public ReadOnly Property FontName1() As String
        Get
            Return cboFont.Text
        End Get

    End Property
    Private Sub FontSetting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim ifc As System.Drawing.Text.InstalledFontCollection = New System.Drawing.Text.InstalledFontCollection()
            cboFont.DataSource = ifc.Families
            cboFont.DisplayMember = "Name"
            Dim configFontName As String = GetAppSettingConfig("FormFontName").Trim()
            Dim rs As ADODB.Recordset = ct.GetTable("select * from XSCFormData where CLASSNAME='" + Me.ClassNameFontSetting + "'")
            If rs IsNot Nothing OrElse rs.EOF = False Then
                If rs("FontName").Value IsNot DBNull.Value Then
                    Dim strFontName = CStr(rs("FontName").Value)
                    If strFontName <> "" Then
                        configFontName = strFontName
                    End If
                End If
                rs.Close()
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rs) '20100531
                rs = Nothing
            End If
            cboFont.Text = configFontName
        Catch ex As Exception
            UTIL.CException.SaveExcepiton(UTIL.ErrorType.Error, ex, MethodBase.GetCurrentMethod.GetType()) 'A-2009-10-11
        End Try

    End Sub

    Private Sub MyButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButton1.Click
        Dim strSql As String = "Update XSCFormData set FontName='" + cboFont.Text + "' where CLASSNAME='" + Me.ClassNameFontSetting + "'"
        ct.ExecuteSql(strSql)
        ShowMessageBox("修改成功")
    End Sub
End Class
